@use './colors.module.scss' as *;

.chip {
  --font-size: 14px;
  --font-size-icon: 18px;
  --padding: 8px;

  color: var(--md-sys-color-on-surface-variant);
  background-color: rgba(0, 0, 0, 0.09);
  display: inline-flex;
  white-space: nowrap;
  gap: 8px;
  margin: 0;
  height: 32px;
  padding-left: var(--padding);
  padding-right: var(--padding);  
  font-size: var(--font-size);
  font-weight: 500;    
  border-radius: 8px;
  align-items: center;
  user-select: none;
  vertical-align: top;

  &:focus {
    outline: none;
    background-color: var(--md-sys-color-primary);
    color:  var(--md-sys-color-on-primary);
  }
}

.chip.outlined {
  background-color: transparent;
  border-color: var(--md-sys-color-outline);
  border-width: 1px;
  border-style: solid;
}

.chip > img {
  margin: 0;
  width: 24px;
  height: 24px;
  object-fit: cover;
  border-radius: 12px;
}

.chip > .material-icons {
  font-size: var(--font-size-icon);
  @extend .on-surface-variant-text;
}

.chip .close {
  border-radius: 50%;
  height: 24px;
  width: 24px;
  padding: 0;
  display: grid;
  justify-content: center;
  align-content: center;
  cursor: pointer;
}

.chip .close:hover {
  background-color: #8888;
}

//--------------------------

.chips {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  border: none;
  box-shadow: none;
  margin: 0 0 8px 0;
  padding: 4px;
  // min-height: 45px;
  outline: none;
  transition: all .3s;

  &.focus {
    border-bottom: 1px solid var(--md-sys-color-primary);
    box-shadow: 0 1px 0 0 var(--md-sys-color-primary);
  }

  &.input-field {
    border-bottom: 1px solid var(--md-sys-color-on-surface-variant);

    &:hover {
      cursor: text;
    }
  }

  input:not([type]):not(.browser-default).input {
    background: none;
    border: 0;
    color: var(--md-sys-color-on-background);
    display: inline-block;
    font-size: 16px;
    // height: 32px;
    // line-height: 32px;
    height: 32px;
    outline: 0;
    margin: 0;
    padding: 0;
    width: 120px;
    width: fit-content;
    min-width: 100px;
    max-width: 200px;

    &:focus {
      border: 0;
      box-shadow: none;
    }
  }

  // Autocomplete
  .autocomplete-content {
    margin-top: 0;
    margin-bottom: 0;
  }
}

// Form prefix
.prefix ~ .chips {
  margin-left: 3rem;
  width: 92%;
  width: calc(100% - 3rem);
}

// Form suffix
.suffix ~ .chips {
  margin-right: 3rem;
  width: 92%;
  width: calc(100% - 3rem);
}

.chips:empty ~ label  {
  font-size: 0.8rem;
  transform: translateY(-140%);
}
